<template>
	<view>
		<myhead left="1"></myhead>
		<view class="tit">添加USDT地址</view>
		<view class="inputList">
		    <view class="title">地址</view>
			<span class="tbNum">
				<input placeholder="输入或长按粘贴地址" v-model="codeTxt"></input>
				<view @tap='codeBtn' class="qbBtn">扫码</view>
			</span>
		</view>
		<view class="inputList">
		    <view class="title">备注</view>
		    <input placeholder="输入地址备注" v-model="txt"></input>
		</view>
		<view class="btn" @tap="btn">确定</view>
	</view>
</template>

<script>
	const http = require('../../utils/http.js');
	export default {
		data() {
			return {
				codeTxt:null,
				txt:null
			}
		},
		methods: {
			codeBtn:function(){
				var that=this
				uni.scanCode({
				    success: function (res) {
				        console.log('条码类型：' + res.scanType);
				        console.log('条码内容：' + res.result);
						that.codeTxt=res.result
				    }
				});
			},
			btn:function(){
				if(!this.codeTxt){
					uni.showToast({
					  title: '请填写提币地址',
					  icon: 'none'
					});
					return false
				}
				if(!this.txt){
					uni.showToast({
					  title: '请填写备注',
					  icon: 'none'
					});
					return false
				}
				uni.showLoading({
				    title: '加载中'
				});
				http.post('/api/user/addMyAddress',{address:this.codeTxt,remark:this.txt}).then(res => {
					//console.log(res)
					uni.showToast({
					  title: res.message,
					  icon: 'none',
					  duration:1000
					});
					uni.hideLoading();
					if (res.code == 200) {
						setTimeout(function () {
						    uni.navigateBack({
						        delta: 1
						    });
						}, 1000);
					}
				})
			}
		}
	}
</script>

<style>
	.tit{
		padding: 8vw;
		font-size: 7vw;
		color: #333333;
	}
	.inputList{
		padding: 0 8vw;
		margin-bottom: 6vw;
	}
	.inputList .title{
		margin-bottom: 2vw;
		font-size: 3.6vw;
		color: #999999;
	}
	.inputList input{
		height: 12vw;
		line-height: 12vw;
		border-bottom: 1px solid #F2F2F2;
	}
	.btn{
		width: 84%;
		padding: 4vw 0;
		font-size: 3.5vw;
		border-radius: 1.8vw;
		background-image: linear-gradient(45deg, #24EBA9, #10C7B2);
		color: #FFFFFF;
		text-align: center;
		margin: 0 auto;
		margin-top: 10vw;
	}
	.tbNum{
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	.tbNum input{
		width: 80%;
	}
	.qbBtn{
		width: 20%;
		text-align: center;
		color: #24EBA9;
		font-size: 3.8vw;
	}
</style>
